package com.dzqc.fly.service.impl;

import com.dzqc.fly.common.PageUtils;
import com.dzqc.fly.db.dao.TbLeaveDao;
import com.dzqc.fly.db.dao.TbUserDao;
import com.dzqc.fly.db.pojo.AppFilePojo;
import com.dzqc.fly.service.LeaveService;
import com.dzqc.fly.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Set;

@Service
public class LeaveServiceImpl implements LeaveService {

    @Autowired
    private TbLeaveDao leaveDao;

    @Override
    public int insertleave(HashMap param) {

        int insertleave = leaveDao.insertleave(param);
        return insertleave;
    }

    @Override
    public int insertleaveshenpi(HashMap param) {
        return leaveDao.insertleaveshenpi(param);
    }

    @Override
    public int insertfiles(AppFilePojo appFilePojo) {
        return leaveDao.insertfiles(appFilePojo);
    }

    @Override
    public PageUtils searchLeaveList(HashMap param) {

        ArrayList<HashMap> list=leaveDao.searchLeaveList(param);
        long count=leaveDao.searchLeaveListCount(param);
        int start=(Integer) param.get("start");
        int length=(Integer) param.get("length");
        PageUtils pageUtils=new PageUtils(list,count,start,length);
        return pageUtils;
    }

    @Override
    public HashMap searchLeaveDetail(HashMap param) {
        return leaveDao.searchLeaveDetail(param);
    }

    @Override
    public LinkedList<HashMap> searchLeaveDetailFiles(HashMap param) {
        LinkedList<HashMap> filesMaps = leaveDao.searchLeaveDetailFiles(param);

        return filesMaps;
    }

    @Override
    public PageUtils searchLeaveListDone(HashMap param) {
        ArrayList<HashMap> list=leaveDao.searchLeaveListDone(param);
        long count=leaveDao.searchLeaveListCountDone(param);
        int start=(Integer) param.get("start");
        int length=(Integer) param.get("length");
        PageUtils pageUtils=new PageUtils(list,count,start,length);
        return pageUtils;
    }

    @Override
    public LinkedList<HashMap> searchMonth(int userId) {
        return leaveDao.searchMonth(userId);
    }

    @Override
    public LinkedList<HashMap> searchNumOfStudentLeave(HashMap param) {
        return leaveDao.searchNumOfStudentLeave(param);
    }

    @Override
    public int updateUnfinishedLeaveStatus(HashMap param) {
        return leaveDao.updateUnfinishedLeaveStatus(param);
    }

    @Override
    public HashMap searchLeaveDetail2FinishedLeave(HashMap param) {
        return leaveDao.searchLeaveDetail2FinishedLeave(param);
    }

    @Override
    public int updateFinishedLeave(HashMap param) {
        return leaveDao.updateFinishedLeave(param);
    }

    @Override
    public int updateLapseLeave(HashMap param) {
        return leaveDao.updateLapseLeave(param);
    }
}
